//
//  LauchViewController.m
//  SoundPill
//
//  Created by 宋鹏鹏 on 15/5/22.
//  Copyright (c) 2015年 宋旭东. All rights reserved.
//

#import "LauchViewController.h"
#import "UIViewExt.h"
#import "LoginViewController.h"
#define Screen_height [[UIScreen mainScreen] bounds].size.height
#define Screen_width  [[UIScreen mainScreen] bounds].size.width
@interface LauchViewController ()
@property (strong, nonatomic) UIImageView *backgroundImageView;
@end

@implementation LauchViewController
- (void)loadView
{
 
    
    UIView *view = [[UIView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
    view.backgroundColor = [UIColor whiteColor];
    self.view = view;
    
    self.backgroundImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, Screen_width, Screen_height)];
    self.backgroundImageView.image = [UIImage imageNamed:@"loginbackground"];
    self.backgroundImageView.alpha = 0;
    [self.view addSubview:self.backgroundImageView];
//    [self createSkipButton];
//    [self registerAndLogin];
    
    // 加载logo视图
    [self loadLogoView];
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    
}
#pragma mark - 先逛逛按钮
- (void)createSkipButton
{
    // 先逛逛
    UIButton *skipButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [skipButton setFrame:CGRectMake(Screen_width - 70, 18, 60, 60)];
    [skipButton setTitle:@"跳过" forState:UIControlStateNormal];
    skipButton.layer.cornerRadius = 30;
    skipButton.layer.masksToBounds = YES;
    skipButton.titleLabel.font = [UIFont fontWithName:@"Helvetica" size:14.0];
    [skipButton setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
    skipButton.alpha = 0.5;
    [skipButton setBackgroundColor:[UIColor whiteColor]];
    [self.view addSubview:skipButton];
}


#pragma mark 创建登录和注册按钮
- (void)registerAndLogin
{
    // 登录按钮
    UIButton *loginButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [loginButton setFrame:CGRectMake(15, Screen_height - 0.07 * Screen_height - 40, Screen_width / 2 - 15 -8, 0.07 * Screen_height)];
    [loginButton setBackgroundColor:[UIColor whiteColor]];
    [loginButton setTitle:@"登 录" forState:UIControlStateNormal];
    [loginButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [self.view addSubview:loginButton];
    
    // 注册按钮
    UIButton *registerButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [registerButton setFrame:CGRectMake(Screen_width / 2 + 8, Screen_height - 0.07 * Screen_height - 40, Screen_width / 2 - 15 -8, 0.07 * Screen_height)];
    [registerButton setBackgroundColor:[UIColor clearColor]];
    [registerButton setTitle:@"注册" forState:UIControlStateNormal];
    [registerButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    registerButton.layer.borderWidth = 4;
    registerButton.layer.borderColor = [[UIColor whiteColor] CGColor];
    [self.view addSubview:registerButton];
    
}

- (void)loadLogoView
{
    //点赞动画
    [UIView animateWithDuration: 1.0f animations:^{
        self.backgroundImageView.alpha = 1;
    }completion:^(BOOL finished) {
        LoginViewController *login = [[LoginViewController alloc] init];
        self.view.window.rootViewController = login;
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
